﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sort
{
    class InsertSort
    {
        public static void Sort(int[] arr, int beg, int end)
        {
            for (int i = 1; i < arr.Length; i++)
            {
                int iTemp = arr[i];

                int j = 0;
                for (j = i - 1; j >= 0; j--)
                {
                    if (arr[j] > iTemp)
                        arr[j + 1] = arr[j];
                    else
                        break;
                }

                arr[j + 1] = iTemp;
            }
        }

        public static void SellSort(int[] arr, int beg, int end)
        {
            int step = arr.Length / 2;

            while(step >= 1)
            {
                for (int i = step; i < arr.Length; i++)
                {
                    int j = 0;
                    int iTemp = arr[i];
                    for (j = i - step; j >= 0; j -= step)
                    {
                        if (arr[j] > iTemp)
                            arr[j + step] = arr[j];
                        else
                            break;
                    }
                    arr[j + step] = iTemp;
                }

                step /= 2;
            }
        }
    }
}
